// WndSubclass.h: interface for the CWndSubclass class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_WNDSUBCLASS_H__BA9A999F_6470_11D9_9AC5_0050BAD093CF__INCLUDED_)
#define AFX_WNDSUBCLASS_H__BA9A999F_6470_11D9_9AC5_0050BAD093CF__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class CWndSubclass 
{
public:
	CWndSubclass();
	~CWndSubclass();

public:
	// Subclass a window. Hook(NULL) to unhook (Automatic on WM_NCDESTROY)
	virtual BOOL SubclassWindow(HWND hWnd);
	virtual BOOL UnSubclassWindow();
	BOOL IsSubclassed()	{ return m_hWndHooked!=NULL; }

public:
	friend LRESULT CALLBACK HookWndProc(HWND, UINT, WPARAM, LPARAM);
	friend class CWndSubclassMap;

protected:
	HWND			m_hWndHooked;		// The window hooked
	WNDPROC			m_pOldWndProc;		// Original window proc
	CWndSubclass*	m_pNext;			// Next in chain of hooks for this window

	// Override this to handle messages in specific handlers
	virtual LRESULT WindowProc(UINT msg, WPARAM wp, LPARAM lp);
	LRESULT Default();
};

#endif // !defined(AFX_WNDSUBCLASS_H__BA9A999F_6470_11D9_9AC5_0050BAD093CF__INCLUDED_)
